package com.hdugraduate;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;

public class Setting extends Activity{
	Button gpsSync;
	Button loginOnSetting;
	
	OnClickListener gpsSynClickListener;
	OnClickListener lgOnClickListener;
	
	@Override
	public void onCreate(Bundle savedInstanceState){
		super.onCreate(savedInstanceState);
		lgOnClickListener = new OnClickListener(){
			public void onClick(View v){
				Intent lgIntent = new Intent(Setting.this, AccountLogin.class);
				startActivity(lgIntent);
			}
		};
		gpsSynClickListener = new OnClickListener(){
			public void onClick(View v){
				Intent gpsSyncIntent = new Intent(Setting.this, GpsSync.class);
				startActivity(gpsSyncIntent);
			}
		};
		setContentView(R.layout.setting);
		gpsSync =(Button)findViewById(R.id.gpsSycButton);
		loginOnSetting = (Button)findViewById(R.id.LoginButton);
		gpsSync.setOnClickListener(gpsSynClickListener);
		loginOnSetting.setOnClickListener(lgOnClickListener);
	}
	public boolean onCreateOptionsMenu(Menu menu){
		menu.add(Menu.NONE,0,0,"MainMenu");
		menu.add(Menu.NONE,1,1,"About");
		return super.onCreateOptionsMenu(menu);
	}
	
	public boolean onOptionsItemSelected(MenuItem item){
    	super.onOptionsItemSelected(item);
    	switch(item.getItemId()){
    		case 0:
    			Intent menuIntentMainMenuOnSetting = new Intent(Setting.this,MainMenu.class);
    			startActivity(menuIntentMainMenuOnSetting);
    			break;
    		case 1:
    			Intent menuIntentAboutOnSetting = new Intent(Setting.this,About.class);
    			startActivity(menuIntentAboutOnSetting);
    			break;
    		case 2:
    			finish();
    			break;
    	}
    	return true;
    }
}
